package ht;

import java.util.Map;
import java.util.*;

// 注释
/*
ver: java 1.5.0+
*/

/**
 * 文档
 * 
 * @author ht
 */
public class EasyJava {
    public static void mute(Object... ps) {
    }

    public static void vari() {
        System.out.println("变量常量");
        int i = 0;
        long l = 0;
        float f = 0.0f;
        double d = 0.0;
        final int ci = 1;

        mute(i, l, f, d, ci);
    }

    public static void stri() {
        System.out.println("字符串");
        String s = "a\nb";
        s = String.format("a%sb", s);

        String lines = null;

        mute(s, lines);
    }

    public static void coll() {
        System.out.println("数组集合");
        int[] arr = { 1, 2, 3 };
        arr = new int[] {};

        List<Integer> list = new ArrayList<>();
        Set<Integer> set = new HashSet<>();
        Map<String, Integer> map = new HashMap<>();

        for (Integer k : arr) {
            mute(k);
        }
        for (Integer k : list) {
            mute(k);
        }
        for (Integer k : set) {
            mute(k);
        }
        for (Map.Entry<String, Integer> e : map.entrySet()) {
            mute(e.getKey(), e.getValue());
        }
    }

    public static void func() {
        System.out.println("函数");

    }

    public static void clas() {
        System.out.println("类和对象");
        String a = "a";
        String b = "b";
        class Inner {
            String a = "i_a";

            void f() {
                mute(a); //i_a
                mute(b);
            }
        }

        Inner inner = new Inner();
        inner.f();

        new ClsSub().f(a); //ClsSuba

        mute(a); //a
    }

    public static void othe() {
        System.out.println("其它");
        //try-with-resource
        // try(Reader r=new FileReader("")){
            // r.readline();
        // }
    }

    public static void main(String[] argv) {
        System.out.println("Hello, World!");
        EasyJava.vari();
        EasyJava.stri();
        EasyJava.coll();
        EasyJava.func();
        EasyJava.clas();
        EasyJava.othe();
    }
}

interface If {
    String f(String a);
}

class Cls implements If {
    public String f(String a) {
        return "Cls" + a;
    }
}

class ClsSub extends Cls {
    @Override
    public String f(String a) {
        return "ClsSub" + a;
    }
}
